package com.maxjay.common.util.encode;

import java.io.UnsupportedEncodingException;

import com.maxjay.common.exception.ERR;
import com.maxjay.common.exception.GeneException;

public class EncodeUtil {
	
	public static final String ISO_8859_1 = "ISO-8859-1";
	public static final String GBK = "GBK";
	public static final String UTF_8 = "UTF-8";
	
	/**
	 * 转换字符串的编码方式
	 * 
	 * @param sourceStr
	 * @param sourceEncode
	 * @param destEncode
	 * @return
	 */
	public static String convertStrEncode(String sourceStr, String sourceEncode, String destEncode){
		String destStr = "";
		try {
			destStr = new String(sourceStr.getBytes(sourceEncode), destEncode);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			throw GeneException.getGeneException(ERR.ERROR_ERR_MSG, e);
		}
		return destStr;
	}

}
